package instanceofTest;

/**
 * Created by LeeXyan on 2017/05/06 10:14
 */
public class Testconert {
    public static void main(String[] args) {
        Animal a = new Animal("monkey");
        Cat c = new Cat("mimi","white");
        Dog d = new Dog("beibei","black");

        System.out.println(a instanceof Animal);
        System.out.println(c instanceof Animal);
        System.out.println(d instanceof Animal);
        System.out.println(a instanceof Dog);

        a = new Dog("xiaohei","yellow");//狗也是animal 所以a能直接新建dog对象 但是不能调用dog的方法
        System.out.println(a instanceof Animal);
        System.out.println(a instanceof Dog);
        System.out.println(a.name);
//System.out.println(a.furclor);
        Dog d1 = (Dog) a;
        System.out.println(d1.furclor);
        System.out.println(d1.name);
    }
}
